package com.cos.lession47.services.impl;

import com.cos.lession47.dao.EmpDao;
import com.cos.lession47.dao.impl.EmpDaoImpl;
import com.cos.lession47.entity.Emp;
import com.cos.lession47.services.EmpServices;
import com.cos.lession47.util.StringUtil;

import java.sql.SQLException;

/**
 * @author: COS
 * @time: 2022/2/28 14:35
 * @description:
 */
public class EmpServicesImpl implements EmpServices {
    private EmpDao ed = new EmpDaoImpl();

    @Override
    public boolean changePwd(String pwd, Integer eno) {
        try {
            if (ed.changePwd(pwd,eno)>0) {
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public Emp getEmpInfoByPhone(String phone) {
        try {
            if (StringUtil.isNotEmpty(phone)) {
                return ed.getEmpInfoByPhone(phone);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public boolean addEmp(Emp e) {
        try {
            if (ed.addEmp(e)>0) {
                return true;
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return false;
    }
}
